<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head>


<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 9">
<meta name="Originator" content="Microsoft Word 9">
<link rel="File-List" href="http://uva.onlinejudge.org/external/100/b_files/filelist.xml">
<title>Problem B - The Twin Towers</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>Administrator</o:Author>
  <o:LastAuthor>Administrator</o:LastAuthor>
  <o:Revision>3</o:Revision>
  <o:TotalTime>2</o:TotalTime>
  <o:Created>2001-01-10T10:34:00Z</o:Created>
  <o:LastSaved>2001-01-10T10:55:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>315</o:Words>
  <o:Characters>1801</o:Characters>
  <o:Company>BUET</o:Company>
  <o:Lines>15</o:Lines>
  <o:Paragraphs>3</o:Paragraphs>
  <o:CharactersWithSpaces>2211</o:CharactersWithSpaces>
  <o:Version>9.2720</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<style>
<!--
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
em
	{mso-bidi-font-style:normal;}
p.Preformatted, li.Preformatted, div.Preformatted
	{mso-style-name:Preformatted;
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:none;
	tab-stops:0in 47.95pt 95.9pt 143.85pt 191.8pt 239.75pt 287.7pt 335.65pt 383.6pt 431.55pt 479.5pt;
	layout-grid-mode:char;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
</head><body style="" lang="EN-US">

<div class="Section1">

<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><font size="5">Problem B</font></b></p>


<p class="MsoNormal" style="text-align: center;" align="center"><b style=""><font size="6">The Twin Towers</font></b></p>


<p class="MsoNormal" style="text-align: center;" align="center"><b style="">Input: </b>standard input<b style=""><o:p></o:p></b></p>

<p class="MsoNormal" style="text-align: center;" align="center"><b style="">Output: </b>standard output</p>

<p class="MsoNormal" style="text-align: justify;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></p>

<p class="MsoNormal" style="text-align: justify;">Once upon a time, in an ancient Empire,
there were two towers of dissimilar shapes in two different cities. The towers
were built by putting circular tiles one upon another. Each of the tiles was of
the same height and had integral radius. It is no wonder that though the two
towers were of dissimilar shape, they had many tiles in common. </p>

<p class="MsoNormal" style="text-align: justify; text-indent: 0.5in;">However, more
than thousand years after they were built, the Emperor ordered his architects
to remove some of the tiles from the two towers so that they have exactly the
same shape and size, and at the same time remain as high as possible. The order
of the tiles in the new towers must remain the same as they were in the
original towers. The Emperor thought that, in this way the two towers might be
able to stand as the symbol of harmony and equality between the two cities. He
decided to name them the<i style=""> Twin Towers</i>.</p>

<p class="MsoNormal" style="text-align: justify; text-indent: 0.5in;">Now, about two
thousand years later, you are challenged with an even simpler problem: given
the descriptions of two dissimilar towers you are asked only to find out the
number of tiles in the highest twin towers that can be built from them. </p>

<p class="MsoNormal" style="text-align: justify;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></p>

<p class="MsoNormal" style="text-align: justify;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><font size="5">Input</font></b></p>


<p class="MsoNormal" style="text-align: justify;">The input file consists of
several data blocks. Each data block describes a pair of towers. </p>

<p class="MsoNormal" style="text-align: justify; text-indent: 0.5in;">The first line
of a data block contains two integers N1 and N2 (1 &lt;= N1, N2 &lt;= 100) indicating the
number of tiles respectively in the two towers. The next line contains N1 positive integers giving the
radii of the tiles (from top to bottom) in the first tower. Then follows
another line containing N2 integers
giving the radii of the tiles (from top to bottom) in the second tower. </p>

<p class="MsoNormal" style="text-align: justify; text-indent: 0.5in;">The input file
terminates with two zeros for N1 and N2.</p>

<p class="MsoNormal" style="text-align: justify;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><font size="5">Output</font></b></p>


<p class="MsoNormal" style="text-align: justify;">For each pair of towers in the
input first output the twin tower number followed by the number of tiles (in
one tower) in the highest possible twin towers that can be built from them.
Print a blank line after the output of each data set.<b style=""><span style="font-size: 14pt;"><o:p></o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><span style="font-size: 14pt;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></b></p>

<p class="MsoNormal" style="text-align: justify;"><b style=""><font size="5">Sample Input</font></b></p>
<font face="Courier" size="3">

7 6<br>

20
15 10 15 25 20 15<br>

15
25 10 20 15 20<br>

8
9<br>

10
20 20 10 20 10 20 10<br>

20
10 20 10 10 20 10 10 20<br>

0
0<br>
</font>
<p class="Preformatted"><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;;"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>


<p class="MsoNormal" style="text-align: justify;"><b style=""><font size="5">Sample Output</font></b></p>
<font face="Courier" size="3">

Twin Towers #1<br>

Number of Tiles : 4<br>

<br>
Twin Towers #2<br>

Number of Tiles : 6<br>

<br>
</font>
</div>
<font face="Times New Roman"> 
____________________________________________________________________________________<br>
Rezaul Alam Chowdhury
</font></body></html>